var MAnim=cc.Node.extend({
	lastDel:0,//距离上一个动画帧的值
	curIndex:0,
	SFFList:null,
	SpriteList:null,
	nEndFrame:1,//上一帧结束，下一帧开始，返回上一帧，最后一针结束置为0
	clsnds:null,
	clsnas:null,
	init:function(name,type){

		var sffname=eval(name+"_sff")

		this.scheduleUpdate();

		var typeStr=parseInt(type);

		this.SFFList=new Array();
		this.SpriteList=new Array();


		var sffdata=sffname[typeStr];
		for(i=0;i<sffdata.length;++i)
		{
			var sff=new SFFData(name,typeStr,i);
			sff.filename="";
			this.SFFList[i]=sff;

			var spr=cc.Sprite.createWithSpriteFrameName(name+
				"_"+sff.group+"_"+sff.no+".png");

			spr.setAnchorPoint(0,1);
			this.SpriteList[i]=spr;
		}
		//this.addChild(this.SpriteList[0]);
		this.curIndex=0;
		this.adjustCurSprite();

	},
	ctor:function(name,data){
		this._super();
		this.init(name,data);
	},
	updateAnim:function(dt){//以秒为单位
		this.lastDel+=dt;

		var sffdata=this.SFFList[this.curIndex];
		if (this.lastDel>=1/60*sffdata.delay)
		{
			//移除sprite
			this.lastDel=0;
			this.removeChild(this.SpriteList[this.curIndex]);

			this.nEndFrame=this.curIndex;
			this.curIndex+=1;

			if(this.curIndex>this.SFFList.length-1)
			{
				this.curIndex=0;
				this.nEndFrame=0;
			}else
			{
				this.nEndFrame=this.curIndex+1;
			}

			//下一帧sprite
			this.adjustCurSprite();
			//设置偏移，中心点


			//设置当前帧的碰撞框
			var clsnds=this.SFFList[this.curIndex].clsnds;
			var clsnas=this.SFFList[this.curIndex].clsnas;

			if(clsnds)//受击框保持之前帧的
			{
				this.clsnds=clsnds;
			}

			//攻击框下一帧没有就清空
			if(clsnas){
				this.clsnas=clsnas;
			}else
			{
				this.clsnas=null;
			}
		}
			
	},
	adjustCurSprite:function(){
		//以
		var sffdata=this.SFFList[this.curIndex];
		var frame=this.SpriteList[this.curIndex];
		sffdata=this.SFFList[this.curIndex];
		frame.setPosition(-sffdata.anchor_x,sffdata.anchor_y);
		this.addChild(frame);
	},
	getCurFrame:function(){
		return this.nEndFrame;
	},
	resetAnim:function(){
		this.removeChild(this.SpriteList[this.curIndex]);

		this.curIndex=0;
		this.nEndFrame=1;
		this.adjustCurSprite();
	},
	getClsnds:function(){//获取当前的受击框
		return this.clsnds;
	},
	getClsnas:function(){
		return this.clsnas;
	}
});